home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / netclb23 / examples.exe / VERPASS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-20  |  2.9 KB  |  81 lines

  1. /***************************************************************************/
  2. /* File:             VERPASS.C                                             */
  3. /*                                                                         */
  4. /* Function:         Verifies a Netware Users password.                    */
  5. /*                                                                         */
  6. /* Usage:            verpass username password                             */
  7. /*                                                                         */
  8. /* Functions Called: GetPreferredConnectionID                              */
  9. /*                   GetDefaultConnectionID                                */
  10. /*                   SetPreferredConnectionID                              */
  11. /*                   GetPrimaryConnectionID                                */
  12. /*                   ISShellLoaded                                         */
  13. /*                   GetBinderyObjectID                                    */
  14. /*                   EncryptPassword                                       */
  15. /*                   VerifyObjectPasswordEncrypted                         */
  16. /*                   VerifyBinderyObjectPassword                           */
  17. /*                                                                         */
  18. /***************************************************************************/
  19.  
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22. #include <string.h>
  23.  
  24. #include "netware.h"
  25.  
  26. void main(int argc,char *argv[])
  27. {
  28. int prefserver;
  29. int thisserver;
  30. byte encrypt[8];
  31. long objectID;
  32. int r;
  33.  
  34.    if (argc != 3)
  35.    {
  36.        printf("Usage is: VERPASS <user name> <password>\n");
  37.        exit(0);
  38.    }
  39.  
  40.    if (IsShellLoaded() != SUCCESS)
  41.    {
  42.       printf("*** No netware shell loaded ***\n");
  43.       exit(255);
  44.    }
  45.  
  46.    if ((prefserver = GetPreferredConnectionID()) == 0)
  47.    {
  48.       if ((thisserver = GetDefaultConnectionID()) == 0)
  49.          thisserver = GetPrimaryConnectionID();
  50.       SetPreferredConnectionID( thisserver );
  51.    }
  52.    else
  53.       thisserver = prefserver;
  54.  
  55.    strupr(argv[1]);
  56.    strupr(argv[2]);
  57.  
  58.    if ((r=GetBinderyObjectID(USER,argv[1],&objectID)) != 0)
  59.       printf("GetBinderyObjectID returned: %d\n",r);
  60.    else
  61.    if (EncryptPassword(objectID,argv[2],(char *)encrypt) == 0)
  62.    {
  63.       /* Current version of Netware uses encrypted passwords */
  64.       if (VerifyObjectPasswordEncrypted(USER,argv[1],encrypt) != 0)
  65.          printf("*** password is invalid ***\n");
  66.       else
  67.          printf("*** password OK ***\n");
  68.    }
  69.    else
  70.    {
  71.       /* Current version of Netware does not use encrypted passwords */
  72.       if (VerifyBinderyObjectPassword(USER,argv[1],argv[2]) != 0)
  73.          printf("*** password is invalid ***\n");
  74.       else
  75.          printf("*** password OK ***\n");
  76.    }
  77.    
  78.    if (thisserver != prefserver)   /* reset preferred server */
  79.       SetPreferredConnectionID( prefserver );
  80. }
  81.